<?php
# ============================================================================
# 版权所有 Chilcoo.com，并保留所有权利。
# 网站地址: http://www.chilcoo.com/ccerp
# ----------------------------------------------------------------------------
# 这不是一个自由软件！你不能通过任何方式破解本软件.
# 使用:不允许对程序代码以任何形式任何目的的再发布。
# ============================================================================
# $Author: Chilcoo Inc. *
# $Official website  : www.chilcoo.com
# 
# 文件信息:
# File : /config.inc.php
# **函数集文件**

# 时间轴
date_default_timezone_set('Japan');
header("Content-type: text/html; charset=utf-8"); 

class config{
	var $conf_web_path;
	var $conf_lang_folder;
	var $smarty;
	var $temp_page_path;
	var $web_page_period; // 周期
	var $money_use_array = array(
			1=>'商品代金',
			2=>'送料',
			3=>'返金',
			5=>'外国送金',
			6=>'給料',
			8=>'残高',
			9=>'私用',
			10=>'その他',
			11=>'運営費用'
			);
	const cs2_version = '0.8Beta';
	const conf_web_root = '/cs2';
	const conf_web_manager_root = '/_manager';
	const conf_web_imgpath_root = '/images/upload';
	const conf_web_imgpath_32 = '/32/';
	const conf_web_imgpath_100 = '/100/';
	const conf_web_imgpath_600 = '/600/';
	
	const conf_db_type = 'mysql';
	const conf_db_host = 'localhost';// 222.73.218.200 // localhost // mysql241.db.sakura.ne.jp
	const conf_db_user = 'chilcoo';// dantiv // root // chilcoo
	const conf_db_password = 'F0099873a';
	const conf_db_name = 'chilcoo'; // chilcoo
	const conf_db_lang = 'utf8';
	# 数据库超级管理员
	const conf_web_image_jpg = '.jpg';
	const conf_web_superuser = 'admin';
	const conf_web_def_lang = 'ja-jp';
	const conf_web_email = 'd.hoo.jp@gmail.com';
	const conf_web_encode = 'uft-8';
	const conf_web_listcount = 10;
	const conf_web_pagecount = 50;
	const conf_web_power = 'power by Chilcoo Inc.';
	# 加载模板引擎
	const conf_web_template = '/__smarty/templates/';
	const conf_web_lang = '/__smarty/lang/';
	const conf_web_compile = '/__smarty/templates_c/';
	const conf_web_configs = '/__smarty/configs/';
	const conf_web_cache = '/__smarty/cache/';
	const conf_web_left_delimi = '<{';
	const conf_web_right_delim = '}>';
	const conf_web_template_extension = '.html';
	const conf_session_id_token = 'session_id';
	const conf_session_admin = 'session_admin';
	# tokens for session and ajax
	const TOKEN_PRODUCT = '6C0C3A58-AD4C-4981-A080-11224BA8A9E7';
	const TOKEN_GET_ZIPCODE = '3D10D249-DFBA-48F0-A982-ACBD608E7834';
	const TOKEN_ADD_CART = 'CBE0C82F-3B9D-4BCC-9739-004DB1449374';
	const TOKEN_ADD_FAVORITES = '05D85C7B-CF92-42C4-86D5-108DB27A4DB6';
	const TOKEN_ADD_CATEGORY = '970284D6-3B61-4495-B303-76B071AD1F35';
	const TOKEN_GET_CATEGORY = 'C31F3462-BBA7-4CF2-883D-D658DD2F8DC3';
	const TOKEN_GET_COOKIES = '796AD080-F119-48CB-82FC-775A813D5021';
	const TOKEN_ORDER_VIEW = '25B05D10-FB5A-42E5-BEAC-05B14DC857A9';
	const TOKEN_UPDATE_RANK = 'C55F4A1C-D136-445A-A5D1-5D0500BE6318';
	const TOKEN_ADD_CATE = '55947AD2-31F9-4D2F-9EAC-A6C8A6AF07AC';
	const TOKEN_UP_CATE = '8D0383BC-6FF7-45D7-A372-20BE4A80E24E';
	const TOKEN_DEL_CATE = 'CDD294D5-7A7D-47CF-A114-54CDB10BA03B';
	
	const TOKEN_UP_FACT = '0978F5D7-CD53-40D5-B0F7-A86611ADC0F3';
	const TOKEN_DEL_FACT = '319AF369-C3D5-4346-BD18-67593CFFD4BC';
	const TOKEN_ADD_FACT = 'BFC94BD1-0FFE-4140-92E5-7A3ABE0D096D';
	
	const TOKEN_UP_ADMIN = 'BFC94BD1-C3D5-40D5-9EAC-05B14DC857A8';
	const TOKEN_ADD_ADMIN = '8D0383BC-C3D5-4D2F-F119-775A813D5021';
	const TOKEN_DEL_ADMIN = 'C55F4A1C-C3D5-4495-F119-775A813D5021';
	
	const TOKEN_ADD_BANK = '0CED59AE-7121-4D4E-9C96-9DA754CFDF1F';
	const TOKEN_DEL_BANK = 'C0EEE356-3ABE-4DD0-9F84-CE4D2CEA9C5B';
	const TOKEN_UP_BANK = '26DBB547-76D5-4145-B9F5-1342EA74FCD1';
	
	const TOKEN_ADD_PROD = '1F66149D-33D0-4954-B774-03E79A8F5C21';
	const TOKEN_DEL_PROD = '6998E822-BDE6-46E3-AA75-C2B6EF96A23B';
	const TOKEN_UP_PROD = 'C502C584-2892-458A-ADF0-AC2C051A6280';
	
	const TOKEN_ADD_MON = '21A443E5-2A7A-4AFA-8AAD-73A60DE39EA5';
	const TOKEN_DEL_MON = 'B7E6EA92-1FF7-4762-ABB8-DADD45998BC1';
	const TOKEN_UP_MON = 'C0BE3E5E-7FAE-48AA-A3A5-7F09D582BCAF';
	const TOKEN_AUDIT_MON = 'C6DA7DA4-A26D-4E52-8000-98A1FE58D1C4';
	
	const TOKEN_ADD_TEMP = '42E08011-D641-4147-AC92-B853D1C91A9C';
	const TOKEN_DEL_TEMP = '54D797BA-AC1F-4FF0-BD05-C70CFF94D257';
	const TOKEN_UP_TEMP = 'EB3842B5-9865-447A-B19B-F40DCA9F1929';
	const TOKEN_VIEW_TEMP = 'C69E5205-9E47-4A9D-A796-A922040E229D';
	
	const TOKEN_ADD_SHIP = '9977682F-2F8E-4590-9A62-E44A7612320B';
	const TOKEN_DEL_SHIP = '7D106788-625A-4B0F-8A03-A303333C78F3';
	const TOKEN_UP_SHIP = '21FC60EF-FC11-46AA-AFE8-7587118B6A9C';
	
	const TOKEN_ADD_STO = 'A26C6BDE-2326-4B2A-BD18-37C75505CA0A';
	const TOKEN_DEL_STO = 'EAA3E0CD-9E49-4950-932E-28F2B74D56BC';
	const TOKEN_UP_STO = 'F7796B44-19E9-4849-A8E1-D8095DD6CD31';
	const TOKEN_SELL_STO = '244B50D3-AD42-45F8-BA02-379509926906';
	
	const TOKEN_ADD_HNEWS = '00970A19-7924-450B-BE79-C4D8CE141EA5';
	const TOKEN_DEL_HNEWS = '531BDC5B-D11D-49F6-8CA6-AB6215DBF898';
	const TOKEN_UP_HNEWS = 'AA07E660-837E-43A5-AB29-B3635EF49E65';
	
	const TOKEN_ADD_HSELL = '5C6E3724-046E-41F8-A9EA-EF9DFE8FA851';
	const TOKEN_DEL_HSELL = 'EFB4F45A-982A-4CB6-B884-4CD49FC4AA55';
	const TOKEN_UP_HSELL = 'D985C6EB-2A42-4C90-B814-A595E36F8334';
	
	const TOKEN_UPSELL_SELL ='78554877-7167-4AE3-90F0-4B1ABCE33C81';
	
	const TOKEN_LOAD_IMPORTANT = 'F530ED25-145D-4BFC-A8B9-4AA938865C7F';
	const TOKEN_LOAD_CATEGORY = '99BE74A3-E80E-4E89-AFCD-1ED06034EE9B';
	const TOKEN_LOAD_CATEGORY_BACK = '6BBEB9B0-6159-4571-BB39-69A678188B4E';
	const TOKEN_LOAD_FACTORY = 'AC45FDCF-163A-4204-A34F-DEAE56CA736C';
	const TOKEN_LOAD_IMAGES = '604E335B-5ACF-4F4E-98D1-5C9E4D8DFB6C';
	
	function __construct(){
		$this->conf_web_path = dirname(__FILE__);
		$this->temp_page_path = str_replace('/','_',$_SERVER['PHP_SELF']);
	}
	# 获取文件的后缀 
	# return 小写后缀
	function get_ext($filename){
	    $ext= explode('.' , $filename);  //用点号分隔文件名到数组
	    $ext = array_reverse($ext);  //把上面数组倒序
	    return strtolower($ext[0]); //返回倒序数组的第一个值
	}
	
	# 创建新token
	# return token
	function new_token(){
		return md5(time());
	}
	# 创建新Guid
	# return Guid 10000008-1004-2004-3004-100000000012 大写
	function guid(){
	   #if (function_exists('com_create_guid')){
	   #    return com_create_guid();
	   #}else{
       mt_srand((double)microtime()*10000);//optional for php 4.2.0 and up.
       $charid = strtoupper(md5(uniqid(rand(), true)));
       $hyphen = chr(45);// "-"
       $uuid = // chr(123). "{"
               substr($charid, 0, 8).$hyphen
               .substr($charid, 8, 4).$hyphen
               .substr($charid,12, 4).$hyphen
               .substr($charid,16, 4).$hyphen
               .substr($charid,20,12);// .chr(125)"}"
       return strtoupper($uuid);
	   #}
	}
	function set_smarty(){
		# 加载语言系统(所有对应.php语言包全部加载)
		$this->conf_lang_folder = opendir($this->conf_web_path.config::conf_web_lang.config::conf_web_def_lang);
		while (false !== ($file = readdir($this->conf_lang_folder))) {
			if($this->get_ext($file) == 'php'){
				require_once ($this->conf_web_path.config::conf_web_lang.config::conf_web_def_lang.'/'.$file);
			}
		}
		# 加载模板类
		require_once(dirname(__FILE__).'/include/smarty/Smarty.class.php');
		# 模板启动
		$this->smarty = new Smarty();
		$this->smarty->template_dir = $this->conf_web_path.config::conf_web_template;
		$this->smarty->compile_dir = $this->conf_web_path.config::conf_web_compile;
		$this->smarty->config_dir = $this->conf_web_path.config::conf_web_configs;
		$this->smarty->cache_dir = $this->conf_web_path.config::conf_web_cache;
		$this->smarty->left_delimiter = config::conf_web_left_delimi;
		$this->smarty->right_delimiter = config::conf_web_right_delim;
		# 导入超级管理员变量
		$this->smarty->assign('db_superuser',config::conf_web_superuser);
		
		$this->smarty->assign('imgpath32',config::conf_web_root.config::conf_web_imgpath_root.config::conf_web_imgpath_32);
		$this->smarty->assign('imgpath100',config::conf_web_root.config::conf_web_imgpath_root.config::conf_web_imgpath_100);
		$this->smarty->assign('imgpath600',config::conf_web_root.config::conf_web_imgpath_root.config::conf_web_imgpath_600);
		$this->smarty->assign('imgextjpg',config::conf_web_image_jpg);
	}
}

$config = new config();
# 初始化Smarty
$config->set_smarty();
?>